<include file="Public:header" /> <include file="Public:navgation" />
<div class="container-fluid main-content">
  <div class="page-title chart-container"> </div>
  <div class="row">
    <div class="col-md-12">
      <div class="widget-container">
        <div class="heading"> <i class="icon-bar-chart"></i>工作计划 <a class="btn btn-default btn pull-right" data-toggle="modal" href="#myModal2" >筛选</a>
          <if condition="getAccessMenu($accessList, 'Intesys', 'Info_plan', 'insert')"> <a class="btn btn-primary btn pull-right f-fillwidth" data-toggle="modal" href="#myModal">新增</a>
            <form action="__URL__/index" method="post" class="pull-right">
              <input id="one-or-all-val" type="text" name="getall" value="{$getall[1]}" style="display: none;" class="btn btn-primary btn pull-right"/>
              <input  type="submit" value="{$getall[0]}" class="btn btn-primary btn pull-right"/>
            </form>
          </if>
        </div>
        <div class="widget-content padded modal-open"> 
          <!--表格布局（start）-->
          <table id="datatable-editable" class="table table-striped table-bordered dataTable">
            <thead>
              <tr>
                <th class="hidden-xs minwidth55">部门</th>
                <th class="minwidth55">姓名</th>
                <th>标题</th>
                <th class="maxwidth60">状态</th>
                <th class="hidden-xs">开始时间</th>
                <th class="hidden-xs">结束时间</th>
                <th class="minwidth64"></th>
              </tr>
            </thead>
            <volist name="list" id="vo" empty="$empty">
              <tr class="data_list {$key}">
                <td class="hidden-xs">{$vo.groupname}</td>
                <td>{$vo.name}</td>
                <td>{$vo.title}</td>
                <td><eq name="vo['status']" value="1"><span class="label label-success">已完成</span></eq>
                  <eq name="vo['status']" value="3"><span class="label label-warning">未完成</span></eq>
                </td>
                <td class=" hidden-xs">{:date('m月d日 H:i',$vo['starttime'])}</td>
                <td class=" hidden-xs">{:date('m月d日 H:i',$vo['endtime'])}</td>
                <td class="text-center actions"><a class="table-actions fancybox" data-start='{:date("Y-m-d H:i:s",$vo["starttime"])}' data-end='{:date("Y-m-d H:i:s",$vo["endtime"])}'  data-id='{$vo['id']}' href="#fancybox"><i class="icon-eye-open"></i></a>
                  <eq name="vo['member_id']" value="$userInfo['id']">
                    <if condition="getAccessMenu($accessList, 'Intesys', 'Info_plan', 'delete')"> <a class="table-actions delete-row" href="{:U('delete',array('id'=>$vo['id']))}" row="{$key}"><i class="icon-trash text-danger"></i></a> </if>
                    <eq name="vo['status']" value="3">
                      <if condition="getAccessMenu($accessList, 'Intesys', 'Info_plan', 'update')"> <a class="table-actions update f-fillwidth" data-id='{$vo['id']}' href="{:U('update',array('id'=>$vo['id']))}"><i class="icon-pencil"></i></a> <a class="table-actions success"  href="{:U('update',array('id'=>$vo['id'],'statu'=>1))}"><i class="icon-ok text-success"></i></a> </if>
                    </eq>
                  </eq></td>
              </tr>
            </volist>
          </table>
          <!--表格布局（end）--> 
        </div>
      </div>
    </div>
  </div>
  <!--modal start  novalidate action="__URL__/update"-->
  <div class="modal fade" id="myModal3" style="display: none;" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <form method="post" name="formupdate" class="form-horizontal " novalidate action="__URL__/update">
          <div class="modal-header">
            <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
            <h4 class="modal-title">修改</h4>
          </div>
          <div class="modal-body">
            <fieldset>
              <div class="form-group">
                <label class="control-label col-sm-2">标题</label>
                <div class="col-sm-10">
                  <input value="" class="form-control" name="title" type="text" datatype="*">
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-sm-2">可查看人员</label>
                <div class="col-sm-10">
                  <div class="input-group">
                    <input readonly class="form-control f-fillname" type="text">
                    <input name="pid"  class="form-control" type="hidden">
                    <span class="input-group-btn" href="#fancybox2">
                    <button class="btn fancybox" href="#fancybox2" type="button">选择</button>
                    </span> </div>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-sm-2">开始时间</label>
                <div class="col-sm-5" style="z-index:1050;">
                  <div class="input-group date datepicker" data-date-autoclose="true" data-date-format="dd-mm-yyyy">
                    <input placeholder="开始时间" name="starttime" class="form-control" type="text">
                    <span class="input-group-addon"><i class="icon-calendar"></i></span> </div>
                </div>
                <div class="col-sm-5" style="z-index:1051;">
                  <div class="input-group bootstrap-timepicker"> 
                  	<input name="starthour" class="form-control" id="timepicker-modal3" type="text">
                  		<span class="input-group-addon"><i class="icon-time"></i></span>
                    </input>
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-sm-2">结束时间</label>
                <div class="col-sm-5" style="z-index:1050;">
                  <div class="input-group date datepicker" data-date-autoclose="true" data-date-format="dd-mm-yyyy">
                    <input placeholder="结束时间" name="endtime" class="form-control" type="text">
                    <span class="input-group-addon"><i class="icon-calendar"></i></span> </div>
                </div>
                <div class="col-sm-5" style="z-index:1050;">
                  <div class="input-group bootstrap-timepicker">
                    <input name="endhour" class="form-control" id="timepicker-modal4" type="text">
                    	<span class="input-group-addon"><i class="icon-time"></i></span></input></div>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-sm-2">工作内容</label>
                <div class="col-sm-10">
                  <div class="input-group">
                    <input readonly  class="form-control" name="item[]" data-item="0" type="text">
                    <span class="input-group-btn">
                    <button class="btn btn-default f-fillline fancybox" href="#fancybox3" type="button"><span class="icon-pencil"></span>修改</button>
                    </span> 
                  </div>
                </div>
              	<div class="col-xs-12">
                  <button class="btn btn-primary pull-right f-newline">新增一行</button>
                </div>
              </div>
              <div class="form-group"> 
                <label class="control-label col-sm-2">tliy</label>
                <div class="col-sm-10">
                  <html:editor id="editorr" name="content" type="UEDIT" style="height:400px; width:100%;">{$info.content}</html:editor>
                </div>
              </div>
            </fieldset>
          </div>
          <div class="modal-footer">
            <button class="btn btn-primary" id="submit-modify" type="submit">修改</button>
            <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
          </div>
        </form>
      </div>
    </div>
  </div>
  
  <!--modal start-->
  <div class="modal fade" id="myModal" style="display: none;" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <form method="post" name="form" class="form-horizontal" novalidate action="__URL__/insert">
          <div class="modal-header">
            <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
            <h4 class="modal-title">创建</h4>
          </div>
          <div class="modal-body">
            <fieldset>
              <div class="form-group">
                <label class="control-label col-sm-2">标题</label>
                <div class="col-sm-10">
                  <input value="" class="form-control" name="title" type="text" datatype="*">
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-sm-2">可查看人员</label>
                <div class="col-sm-10">
                  <div class="input-group">
                    <input readonly  class="form-control f-fillname" type="text">
                    <input name="pid" class="form-control" type="hidden">
                    <span class="input-group-btn">
                    <button class="btn btn-default fancybox" href="#fancybox2" type="button">选择</button>
                    </span> </div>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-sm-2">开始时间</label>
                <div class="col-sm-5" style="z-index:1050;">
                  <div class="input-group date datepicker" data-date-autoclose="true" data-date-format="dd-mm-yyyy">
                    <input placeholder="开始时间" name="starttime" class="form-control" type="text">
                    <span class="input-group-addon"><i class="icon-calendar"></i></span> </div>
                </div>
                <div class="col-sm-5" style="z-index:1051;">
                  <div class="input-group bootstrap-timepicker">
                    <input name="starthour" class="form-control" id="timepicker-modal2" type="text">
                    <span class="input-group-addon"><i class="icon-time"></i></span>
                    </input>
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-sm-2">结束时间</label>
                <div class="col-sm-5" style="z-index:1050;">
                  <div class="input-group date datepicker" data-date-autoclose="true" data-date-format="dd-mm-yyyy">
                    <input placeholder="结束时间" name="endtime" class="form-control" type="text">
                    <span class="input-group-addon"><i class="icon-calendar"></i></span> </div>
                </div>
                <div class="col-sm-5" style="z-index:1050;">
                  <div class="input-group bootstrap-timepicker">
                    <input name="endhour" class="form-control" id="timepicker-modal" type="text">
                    <span class="input-group-addon"><i class="icon-time"></i></span>
                    </input>
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-sm-2">工作内容</label>
                <div class="col-sm-10">
                  <div class="input-group">
                    <input readonly  class="form-control" name="item[]" data-item="0" type="text">
                    <span class="input-group-btn">
                    <button class="btn btn-default f-fillline fancybox" href="#fancybox3" type="button"><span class="icon-pencil"></span>修改</button>
                    </span> 
                  </div>
                </div>
              	<div class="col-xs-12">
                  <button class="btn btn-primary pull-right f-newline">新增一行</button>
                </div>
              </div>
              <div class="form-group">
              	<label class="control-label col-sm-2">备注</label>
                <div class="col-sm-10"> 
                  <!--<textarea class="form-control summernote" name="content" rows="5"></textarea>-->
                  <html:editor id="editor" name="content" type="UEDIT" style="height:300px; width:100%;"></html:editor>
                </div>
              </div>
            </fieldset>
          </div>
          <div class="modal-footer">
            <button class="btn btn-default" name="type" value="0" type="submit">存储为草稿</button>
            <button class="btn btn-primary" type="submit">确定</button>
            <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
          </div>
        </form>
      </div>
    </div>
  </div>
  <!--modal start-->
  <div class="modal fade" id="myModal4" style="display: none;" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <form method="post" name="form" class="form-horizontal" novalidate action="__URL__/update">
          <div class="modal-header">
            <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
            <h4 class="modal-title">实际完成时间</h4>
          </div>
          <div class="modal-body">
            <fieldset>
              <div class="form-group">
                <label class="control-label col-sm-2">完成时间</label>
                <div class="col-sm-5" style="z-index:1050;">
                  <div class="input-group date datepicker" data-date-autoclose="true" data-date-format="dd-mm-yyyy">
                    <input placeholder="实际完成时间" name="realtime" class="form-control" type="text">
                    <span class="input-group-addon"><i class="icon-calendar"></i></span> </div>
                </div>
                <div class="col-sm-5" style="z-index:1051;">
                  <div class="input-group bootstrap-timepicker">
                    <input name="realhour" class="form-control" id="timepicker-modal5" type="text">
                    <span class="input-group-addon"><i class="icon-time"></i></span>
                    </input>
                  </div>
                </div>
              </div>
            </fieldset>
          </div>
          <div class="modal-footer">
            <button class="btn btn-primary f-confirm" type="submit">完成</button>
            <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
          </div>
        </form>
      </div>
    </div>
  </div>
  <!-- modal end and modal2 start-->
  <div class="modal fade" id="myModal2" style="display: none;" aria-hidden="true">
    <div class="modal-dialog">
      <div class="modal-content">
        <form method="post" name="form"  class="form-horizontal" novalidate action="__URL__/index">
          <div class="modal-header">
            <button aria-hidden="true" class="close" data-dismiss="modal" type="button">×</button>
            <h4 class="modal-title">筛选</h4>
          </div>
          <div class="modal-body">
            <fieldset>
              <div class="form-group">
                <label class="control-label col-sm-2">职员部门</label>
                <div  class="col-sm-5">
                  <select class="form-control groupid" name="groupid">
                    <option value="">选择部门</option>
                    <foreach name="grouplist" item="vo">
                      <option value="{$vo.id}">{$vo.title}</option>
                    </foreach>
                  </select>
                </div>
                <div class="col-sm-5">
                  <select class="form-control memberid" name="member_id">
                    <option value="">选择职员</option>
                  </select>
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-sm-2">日期范围</label>
                <div class="col-sm-5" style="z-index:1050;">
                  <input name="starttime" class="form-control" data-date-autoclose="true" data-date-format="dd-mm-yyyy" id="dpd1" placeholder="开始日期" type="text">
                </div>
                <div class="col-sm-5" style="z-index:1050;">
                  <input name="endtime" class="form-control" data-date-autoclose="true" data-date-format="dd-mm-yyyy" id="dpd2" placeholder="结束日期" type="text">
                </div>
              </div>
              <div class="form-group">
                <label class="control-label col-sm-2">状态</label>
                <div class="col-sm-5">
                  <select class="form-control" name="statu_id">
                    <option value="">选择状态</option>
                    <option value="3">未完成</option>
                    <option value="1">已完成</option>
                  </select>
                </div>
              </div>
            </fieldset>
          </div>
          <div class="modal-footer">
            <button class="btn btn-primary" type="submit">确定</button>
            <button class="btn btn-default-outline" data-dismiss="modal" type="button">关闭</button>
          </div>
        </form>
      </div>
    </div>
  </div>
  <!-- modal end and fancybox start-->
  <div id="fancybox" class="modal-dialog" style="display: none;">
    <h4 class="text-muted">查看</h4>
    <ul class="no-style">
    </ul>
  </div>
  <!-- fancybox end and fancybox start-->
  <div id="fancybox3" class="modal-dialog" style="display: none;">
    <h4 class="text-muted">查看</h4>
    <ul class="no-style">
    	<div class="row">
            <label class="col-xs-2">内容</label>
            <div class="col-xs-10">
              <input value="" class="form-control"  type="text">
            </div>
        </div>
        <div class="row">
        	<button class="btn btn-primary pull-right f-fillinput">确定</button>
        </div>
    </ul>
  </div>
  <!-- fancybox end and fancybox start-->
  <div id="fancybox2" style="display: none;">
    <ul class="nav nav-tabs" role="tablist">
      <foreach name="memberlist" item="vo">
        <li role="presentation"><a href="#{$key}" aria-controls="{$key}" role="tab" data-toggle="tab">{$key}</a></li>
      </foreach>
    </ul>
    <!-- Tab panes -->
    <div class="tab-content" style="min-height:160px">
      <foreach name="memberlist" item="vo">
        <div role="tabpanel" class="tab-pane" id="{$key}">
          <foreach name="vo" item="ko">
            <label class="checkbox-inline">
              <input name="staff" type="checkbox" value="{$ko.id}">
              <span>{$ko.name}</span></label>
          </foreach>
        </div>
      </foreach>
    </div>
    <div class="col-xs-12">
      <label class="checkbox-inline checkall">
        <input type="checkbox">
        <span>全选</span></label>
      <button class="btn btn-primary btn-md pull-right f-getstaff">确定</button>
    </div>
  </div>
  <!-- fancybox end --> 
</div>
<script>
$(document).ready(function(e) {
	var oTable = $("#datatable").DataTable({
						ajax:"__URL__/index",
						"sPaginationType" : "full_numbers",
						"bPaginate":true,
						"iDisplayLength" : 10, 
						"bLengthChange" : true,
						"bSort" : true,
						"bDestroy":true,
					  });
	
});
</script>
<script>
/*$('#one-or-all').on('click',function(e){
		//e.preventDefault();
		//alert(e);
		$("#datatable").DataTable({
			ajax:"__URL__/index",
			data:{'getall':"one"},
			"sPaginationType" : "full_numbers",
			"bPaginate":true,
			"iDisplayLength" : 10, 
			"bLengthChange" : true,
			"bSort" : true,
			"bDestroy":true,
			success:function(result){
				alert(result);
			},
			complete:function(result){
				alert(result);
			}
		});
	});*/
$(".main-content").on("click",".f-fillline",function(e) {
	var f=$($(this).attr("href"));
	f.find("input").val($(this).siblings("input").val());
	f.find(".f-fillinput").attr("data-item",$(this).parents(".input-group").find(".form-control").attr("data-item"));
});
$(".f-fillinput").click(function(e) {
   $("input[data-item='"+Number($(this).attr('data-item'))+"']").val($(this).parent().siblings(".row").find("input").val()); 
   $(".fancybox-close").click();
});
$(".f-newline").click(function(e) {
	e.preventDefault();
	var line=$(this).parent();
    line.before(line.prev().prev().clone());
    line.before(line.prev().prev().clone());
	line.prev().find("input").val("");
	line.prev().find("input").attr("data-item",Number(line.prev().find("input").attr("data-item"))+1);
});
$(".success").click(function(e) {
    e.preventDefault();
    $("#myModal4 form").attr("action",$(this).attr("href"));
    $("#myModal4").modal("show");
});
$(".update").click(function(e) {
    e.preventDefault();
	var Modal=$("#myModal3");
    Modal.find("form").attr("action",$(this).attr("href"));
    Modal.find(".form-group").find('[name="title"]').val($(this).parents(".data_list").find("td:eq(2)").html());
    Modal.find(".form-group").find('[name="starttime"]').val($(this).siblings(".fancybox").attr('data-start').substr(0,10));
    Modal.find(".form-group").find('[name="starthour"]').val($(this).siblings(".fancybox").attr('data-start').substr(11));
    Modal.find(".form-group").find('[name="endtime"]').val($(this).siblings(".fancybox").attr('data-end').substr(0,10));
    Modal.find(".form-group").find('[name="endhour"]').val($(this).siblings(".fancybox").attr('data-end').substr(11));
	//工作内容
    $.getJSON("__URL__/getinfo",{'id':$(this).attr('data-id')},function(data){
        if(data.statu==1){
           Modal.find(".form-group  #editorr #ueditor_0").contents().find("body p").html(data.info['content']);     
           Modal.find(".form-group").find('[name="pid"]').val(data.info['pid']);
        }    
    });
	//工作详细
	Modal.find("input[name='item[]']:not(:last)").each(function(index, element) {
        $(this).parent().parent().prev('label').remove();
		$(this).parent().parent().remove();
    });
	Modal.find("input[name='item[]']:last").val("");
	$.getJSON("__URL__/getitems",{'id':$(this).attr('data-id')},function(data){
		console.log(data);
		if(data.statu==1&&data.items){
			$(data.items).each(function(index, element) {
                var lastitem=Modal.find("input[name='item[]']:last");
				lastitem.val(element);
				lastitem=lastitem.parent().parent();
				lastitem.prev('label').before(lastitem.prev('label').clone());
				lastitem.prev('label').before(lastitem.clone());
            });
			Modal.find("input[name='item[]']:last").parent().parent().prev('label').remove();
			Modal.find("input[name='item[]']:last").parent().parent().remove();
		}
	});
    Modal.modal("show");
});
$(".fancybox").click(function(e) {

    $("#fancybox ul").append("<p> <span class='text-primary'>开始时间:</span>"+$(this).attr('data-start')+"</p>");
    $("#fancybox ul").append("<p><span class='text-primary'>结束时间:</span>"+$(this).attr('data-end')+"</p>");
    $.getJSON("__URL__/getinfo",{'id':$(this).attr('data-id')},function(data){
        if(data.statu==1){
            if(data.info['realtime']!=0){
                $("#fancybox ul").append("<p><span class='text-primary'>实际完成时间:</span> "+format(data.info['realtime']*1000)+"</p>");    
            }
		    $(data.items).each(function(index, element) {
            	$("#fancybox ul").append("<p><span class='text-primary'>内容"+Number(index)+1+":</span> "+element+"</p>");    	
            });
			$("#fancybox ul").append("<p><span class='text-primary'>备注:</span> "+data.info['content']+"</p>");    
        }    
    });
    
});
</script> 
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script> 
<include file="Public:footer" />